import { Module, MiddlewareConsumer, RequestMethod } from '@nestjs/common';
import { MiddleWareTestService } from './middle-ware-test.service';
import { MiddleWareTestController } from './middle-ware-test.controller';
import { Logger } from '../middlewares/logger'
@Module({
  controllers: [MiddleWareTestController],
  providers: [MiddleWareTestService],
})
export class MiddleWareTestModule {
  // 
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(Logger)
      // 指定路由
      // .forRoutes('middleWt');
      // 指定路由和方法
      // .forRoutes({ path: 'middleWt', method: RequestMethod.GET });
      // 还可以直接丢整个控制器，这样这个组件的所有路由都会被中间件拦截
      // .forRoutes(MiddleWareTestController)
      .forRoutes('*')
  }
}
